package com.project.smarthome.common.util;

import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.utils.ViewPortHandler;

import java.text.DecimalFormat;

/**
 * 作者 lunanting on 2016/8/3 15 40.
 * <p/>
 * 邮箱：919530038@qq.com
 */
public class MyValueFormatter implements com.github.mikephil.charting.formatter.ValueFormatter {

    private DecimalFormat mFormat;
    private int mSize;

    public MyValueFormatter() {
        mFormat = new DecimalFormat("###,###,###.##"); // use one decimal
    }

    public MyValueFormatter(int mSize) {
        this.mSize = mSize;
        mFormat = new DecimalFormat("###,###,###.##"); // use one decimal
    }

    @Override
    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
        // write your logic here
        if (mSize != 0 && mSize - 1 == entry.getXIndex()) {
            return "";
        }
        return "   " + mFormat.format(value); // e.g. append pSdk3 dollar-sign
    }
}
